enum HttpMethod { GET, POST, DELETE }

/// 基础请求
/// GET 两种参数方式
/// curl -X GET "https//api/devio.org/uapi/test/test/1" (path)
/// curl -X GET "https//api/devio.org/uapi/test/test?requestPrams=11"  (query)
abstract class BaseRequest {
  /// 请求方式
  HttpMethod httpMethod();

  String baseUrl() {
    return "https://api.devio.org";
  }

  /// GET 请求 路径 拼接的参数
  var pathParams;

  /// 实际请求接口地址
  String path();

  /// 完整请求地址
  String url() {
    var pathStr = path();
    if (pathParams != null) {
      if (path().endsWith("/")) {
        pathStr = "${path()}$pathParams";
      } else {
        pathStr = "${path()}/$pathParams";
      }
    }
    String requestUrl = baseUrl() + '${pathStr}';
    return requestUrl;
  }

  ///  请求头参数
  Map<String, dynamic> header = Map();
  BaseRequest addHeader(String k, Object v) {
    header[k] = v;
    return this;
  }

  ///  请求体参数
  Map<String, Object> params = Map();
  BaseRequest add(String k, Object v) {
    params[k] = v;
    return this;
  }
}
